home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGMISC / FPCHELP.LZH / KERNEL3.HLP < prev    next >
Text File  |  1988-08-01  |  16KB  |  433 lines

  1. KERNEL3.HLP            Edited by J. McKnight    1988-01-30 23:32
  2.  
  3. >TYPE           ( addr len -- )
  4.         TYPE for multitasking systems.
  5.  
  6. .(              ( -- )
  7.         Type the following string on the terminal.
  8.  
  9. (               ( -- )
  10.         The Forth Comment Character. The input stream is skipped  until a ) is
  11.         encountered.
  12.  
  13. TRAVERSE        ( addr direction -- addr' )
  14.         Run through a name field in the specified direction. Terminate when a
  15.         byte whose high order bit is on is detected. 
  16.  
  17. DONE?           ( n -- f )
  18.         True if the input stream is exhaused or state doesn't match.
  19.  
  20. CNHASH          ( cfa -- ya )
  21.         Given CFA, get pointer into >NAME hash table in YSEG.
  22.  
  23. CNSRCH          ( cfa ya maxya -- nfa failf )
  24.         Search for CFA between YA and MAXYA in YSEG. Return NFA and failure
  25.         flag.
  26.  
  27. N>LINK          ( anf -- alf)
  28.         Go from name field address anf to link field address alf.
  29.  
  30. L>NAME          ( alf -- anf )
  31.         Go from link field address alf to name field address alf.
  32.  
  33. BODY>           ( apf -- acf )
  34.         Go from body address apf to code field address acf.
  35.  
  36. NAME>           ( anf -- acf )
  37.         Go from name field address anf to code field address acf.
  38.  
  39. LINK>           ( alf -- acf )
  40.         Go from link field address alf to code field address acf.
  41.  
  42. >BODY           ( acf -- apf )
  43.         Go from code field address acf to body address apf.
  44.  
  45. NO-NAME         ( --- )
  46.         A dummy name, whose name field address is returned by >NAME
  47.         when the real name field can not be found.
  48.  
  49. >NAME           ( acf -- anf )
  50.         Go from code field address acf to name field address anf.
  51.  
  52. >LINK           ( acf -- alf )
  53.         Go from code field address acf to link field address alf.
  54.  
  55. >VIEW           ( acf -- avf )
  56.         Go from code field address acf to view field address avf.
  57.  
  58. VIEW>           ( avf -- acf )
  59.         Go from view field address avf to code field address acf.
  60.  
  61. HASH            ( str-addr voc-ptr -- thread )
  62.  
  63.         Given a string address and a pointer to a set of vocabulary chains,
  64.         returns the actual thread. The hash algorithm used is as follows:
  65.  
  66.                 (((firstchar*2)+secondchar)*2)+count)and(#threads-1)
  67.  
  68.         This seems to provide a good distribution across the 64 threads in
  69.         1000 word FORTH vocabulary.
  70.  
  71.  
  72. (FIND)          ( here alf --- cfa flag | here false )
  73.         Does a search of the dictionary based on a pointer to a vocabulary
  74.         thread and a string.  If it finds the string in the chain, it returns
  75.         a pointer to the CFA field inside the header. This field contains the
  76.         code field address of the body. If it was an immediate word the flag
  77.         returned is a 1. If it is non-immediate the flag returned is a -1. If
  78.         the name was not found, the string address is returned along with a
  79.         flag of zero. Note that links point to links, and are absolute
  80.         addresses.
  81.  
  82. FIND            ( addr -- cfa flag | addr false )
  83.         Run through the vocabulary list searching for the name whose address
  84.         is supplied on the stack. If the name is found, return the code field
  85.         address of the name and a non-zero flag. The flag is -1 if the word is
  86.         non-immediate and 1 if it is immediate. If the name is not found, the
  87.         string address is returned along with a false flag.
  88.  
  89. DEFINED         ( -- here 0 | addr false )
  90.         Look up the next word in the input stream. Return true if it exists,
  91.         otherwise false. Maybe ignore case.
  92.  
  93. ?STACK          ( -- )
  94.         Check for parameter stack underflow or overflow and issue appropriate
  95.         error message if detected.
  96.  
  97. STATUS          ( -- )
  98.         Indicate the current status of the system.
  99.  
  100. INTERPRET       ( -- )
  101.         The Forth Interpret Loop. If the next word is defined, execute it,
  102.         otherwise convert it to a number and push it onto the stack.
  103.  
  104. PRINT           <words-to-be-interpreted> ( -- )
  105.         Interpret the following words, and output to printer.
  106.  
  107. ALLOT           ( n -- )
  108.         Allocate more space in the dictionary.
  109.  
  110. ,               ( n -- )
  111.         Set the contents of the dictionary to the arbitrary 16-bit value on
  112.         the stack. 
  113.  
  114. C,              ( char -- )
  115.         Same as , except uses an 8-bit value.
  116.  
  117. ALIGN           ( -- )
  118.         Used to force even addresses. A noop on the 8086.
  119.  
  120. EVEN            ( -- )
  121.         Makes the top of the stack an EVEN number. A noop on the 8086.
  122.  
  123. COMPILE         <name> ( -- )
  124.         Compile the (typically not-immediate) following word <name> when this
  125.         definition executes. Name is later compiled into the LIST dictionary
  126.         space.
  127.  
  128. CCOMPILE                ( -- )
  129.         Compile the (typically not-immediate) following word <name> when this
  130.         definition executes. Name is later compiled into the CODE dictionary
  131.         space.  This is a special purpose version of COMPILE, used when
  132.         compiling something into the CODE area.
  133.  
  134. IMMEDIATE       ( -- )
  135.         Mark the last Header as an Immediate word.
  136.  
  137. LITERAL         ( n -- )
  138.         Compile the single integer from the stack as a literal.
  139.  
  140. DLITERAL        ( d# -- )
  141.         Compile the double integer from the stack as a literal. 
  142.  
  143. ASCII           <char> ( -- n )
  144.         Compile the next character in the input stream as a literal ASCII
  145.         integer.
  146.  
  147. CONTROL         <char> ( -- n )
  148.         Compile the next character in the input stream as a literal ASCII
  149.         Control Character.
  150.  
  151. CRASH           ( -- )
  152.         Default routine called by execution vectors.
  153.  
  154. ?MISSING        ( f -- )
  155.         Tell user the word does not exist.
  156.  
  157. '               <name> ( -- cfa )
  158.         Return the code field address of the next word <name>.
  159.  
  160. [']             <name> ( -- )
  161.         Like ' only used while compiling
  162.  
  163. [COMPILE]       <name> ( -- )
  164.         Force compilation of an immediate word
  165.  
  166. (")             <string> ( -- addr len )
  167.         Return the address and length of the inline string, and continue
  168.         execution after the string.
  169.  
  170. (.")            <string> ( -- )
  171.         Type the inline string, and continue execution after the string.
  172.  
  173. ,"              <string> ( -- )
  174.         Add the following text string till a " to the dictionary.
  175.  
  176. ."              <string> ( -- )
  177.         Compile the string till a " to be typed out later.
  178.  
  179. "               <string> ( -- )
  180.         Compile the string. Return address and length at runtime.
  181.  
  182. ">$             ( a1 len -- a2 )
  183.         Convert address a1 and length len of a string created with "
  184.         into a counted string address a2.  This word relys on the fact
  185.         that " really creates counted strings, but converts them to
  186.         address and length on execution.
  187.  
  188. FENCE   is the limit address for forgetting.
  189.  
  190. TRIM            ( faddr voc-addr -- )
  191.         ????? Change the 4 hash pointers in a vocabulary so that they are all
  192.         less than a specified value, faddr.
  193.  
  194. (FRGET)         ( code-addr relative-link-addr )
  195.         Forgets part of the dictionary. Both the code address and the header
  196.         address are specified, and may be independent. (FRGET) resets all of
  197.         the links and releases the space.
  198.  
  199. FORGET          <name> ( -- )
  200.         Forget all of the code and headers before <name>. FORGET must be
  201.         used with caution, if you are using DEFERS or UDEFERS, FORGET
  202.         will not know about these chains, so they must be unlinked before
  203.         using FORGET or disaster WILL strike.
  204.  
  205. WHERE           ( ?????
  206.         ????? Locates the screen and position following an error. 
  207.  
  208. ?ERROR          ( ?????
  209.         Maybe indicate an error. Change this to alter ABORT" 
  210.  
  211. (?ERROR)        ( ?????
  212.         Default for ?ERROR. Conditionally execute WHERE and type message.
  213.  
  214. (ABORT")        ( f -- )
  215.         The Runtime code compiled by ABORT". Uses ERROR, and updates return
  216.         stack.
  217.  
  218. ABORT"  <message>"      ( f -- )
  219.         If the flag is true, issue <message> and ABORT.
  220.  
  221. ABORT           ( -- )
  222.         Clear the data stack and QUIT; no message is displayed.
  223.  
  224. ?CONDITION      ( f -- )
  225.         Simple compile time error checking. Usually adequate.
  226.  
  227. >MARK           ( -- addr )
  228.         Set up for a Forward Branch.
  229.  
  230. >RESOLVE                ( addr -- )
  231.         Resolve a Forward Branch.
  232.  
  233. <MARK           ( -- addr )
  234.         Set up for a Backwards Branch.
  235.  
  236. <RESOLVE        ( addr -- )
  237.         Resolve a Backwards Branch.
  238.  
  239. ?>MARK          ( -- f addr )
  240.         Set up a forward Branch with Error Checking.
  241.  
  242. ?>RESOLVE       ( f addr -- )
  243.         Resolve a forward Branch with Error Checking.
  244.  
  245. ?<MARK          ( -- f addr )
  246.         Set up for a Backwards Branch with Error Checking. 
  247.  
  248. ?<RESOLVE       ( f addr -- )
  249.         Resolve a backwards Branch with Error Checking.
  250.  
  251. LEAVE           ( -- )
  252.         Immediately exit a DO-LOOP.
  253.  
  254. ?LEAVE          ( f -- )
  255.         Immediately exit a DO-LOOP if the flag is true; else continue looping.
  256.  
  257. BEGIN           ( -- )
  258.         Used in the form            BEGIN ... AGAIN, 
  259.                                 or  BEGIN ... flag UNTIL, 
  260.                                 or BEGIN ... flag WHILE ... REPEAT
  261.  
  262. AGAIN           ( -- )
  263.         Unconditional jump to just after BEGIN in a BEGIN ... AGAIN loop.
  264.  
  265. UNTIL           ( ? -- )
  266.         Marks end of a BEGIN ... UNTIL loop; terminate if flag ? is true.
  267.  
  268. WHILE           ( ? -- )
  269.         Used in the form  BEGIN <loop> flag WHILE <true> REPEAT.
  270.         Repeat <loop> and <true> clauses while the flag ? is true (really,
  271.         non-zero).
  272.         
  273. REPEAT          ( -- )
  274.         Unconditional backward branch to just after BEGIN in a  
  275.         BEGIN  <loop>  flag WHILE  <true>  REPEAT   loop. 
  276.  
  277. DO              ( limit start -- )
  278.         Initialize a loop structure with index running from start to limit-1. 
  279.         Used in the form   DO ... LOOP   or  DO ... +LOOP
  280.  
  281. ?DO             ( limit start -- )
  282.         Same as DO except that the loop will not be executed if start = lim.
  283.  
  284. LOOP            ( -- )
  285.         Terminate a loop structure. Increment loop index by one and repeat
  286.         <loop-body> until loop index crosses the boundary between limit and
  287.         limit - 1.
  288.         Used in the form   DO <loop-body> LOOP.
  289.  
  290. +LOOP           ( n -- )
  291.         Terminate a loop structure. Increment loop index by n and repeat
  292.         <loop-body> until loop index crosses the boundary between limit and
  293.         limit - 1.
  294.         Used in the form   DO <loop-body> LOOP.
  295.  
  296. IF              ( ? -- )
  297.         Used in the form: ?   IF <true> ELSE <false> THEN  (ELSE is optional).
  298.         If flag ? is false, branches forward to <false> or after THEN.
  299.  
  300. ELSE            ( 
  301.         Used in the form: ? IF <true> ELSE <false> THEN. If flag ? is false,
  302.         branches forward to <false>.
  303.  
  304. THEN            ( -- )
  305.         Terminate a branch structure.
  306.         Used in the form   flag IF ... ELSE ... THEN
  307.  
  308. ,VIEW           ( -- )
  309.         Calculate and compile the VIEW field of the header. 
  310.  
  311. "HEADER         <name> ( -- )
  312.         The string <name> to make a header, and initialize  the code field.
  313.         First we check for duplicates. Then we make  entry in >NAME hash
  314.         table if appropriate. Next lay down the  view field. Then we hook
  315.         in to the correct thread an make the  link field. We set up LAST so
  316.         that it points to our name  field. Then we copy the name to YSEG and
  317.         delimit the name  field bits. Then we make the pointer in the YSEG to
  318.         the CFA.  Then we add a stopper entry to >NAME hash table in case of
  319.         a large ALLOT or end of dictionary. Does all of its work in HEAD
  320.         space, has no effect on CODE space whatsoever.
  321.  
  322. ,CALL           ( -- )
  323.         Compiles a CALL to address ZERO, the actual branch address is set
  324.         later by ;USES or ;CODE.  See CREATE, VARIABLE, CONSTANT & :
  325.  
  326. ,JUMP           ( 
  327.         Compiles a JMP to address ZERO, the actual jump address is set
  328.         later by ;USES or ;CODE.  See CREATE, VARIABLE, CONSTANT & :
  329.  
  330. HEADER          <name> ( -- )
  331.         Creates a NAME header in HEAD space, but compiles absolutely
  332.         nothing in CODE space.  The head created, does point at HERE
  333.         though.
  334.  
  335. CREATE          <name> ( -- )
  336.         Make a header for the next word in the input stream.
  337.  
  338. !CSP            ( -- )
  339.         Save the current stack level for error checking. 
  340.  
  341. ?CSP            ( -- )
  342.         Issue error message if stack has changed.
  343.  
  344. HIDE            ( -- )
  345.         Removes the Last definition from the Header Dictionary.
  346.  
  347. REVEAL          ( -- )
  348.         Activates the Last definition in the Header Dictionary.
  349.  
  350. (;USES)         ( -- )
  351.         Set the code field to the contents of following cell 
  352.  
  353. ;USES           ( -- )
  354.         Similar to the traditional ;CODE except used when  run time code has
  355.         been previously defined.
  356.  
  357. (;CODE)         ( -- )
  358.         Set the code field to the address of the following. 
  359.  
  360. ;CODE           ( -- )
  361.         Used for defining the run time portion of a defining  word in low
  362.         level code.
  363.  
  364. DOES>           ( -- )
  365.         Specifies the run time of a defining word in high  level Forth.
  366.  
  367. ASSEMBLER       ( --- )
  368.         The VOCABULARY that contains all of the assembler definitions.
  369.  
  370. [               ( -- )
  371.         Stop compiling and start interpreting.
  372.  
  373. ]               ( -- )
  374.         The Compiling Loop. First sets Compile State. Looks up the next word
  375.         in the input stream and either executes it or compiles it depending
  376.         upon whether or not it is immediate. If the word is not in the
  377.         dictionary, it converts it to a number, either single or double
  378.         precision depending on whether or not any punctuation was present.
  379.         Continues until input stream is empty or state changes.
  380.  
  381. MAKEDUMMY       <name> ( -- )
  382.         Make a dummy : definitions out of <name>.  Effectively a NOOP,
  383.         used by ANEW.
  384.  
  385. ANEW            <name> ( -- )
  386.         Define A NEW definition <name>.  If <name> already exists, then
  387.         we FORGET it before making the new one.  A nice utility to allow
  388.         re-loading a file again and again for debugging purposes.  I don't
  389.         know where this furst originated, but I learned of it from
  390.         RAY ISAAC at CALOS, a real neat trick.
  391.  
  392. :               ( -- )
  393.         Defines a colon definition. The definition is hidden until it is
  394.         completed, or the user desires recursion. The runtime for : adds a
  395.         nesting level.
  396.  
  397. ;               ( -- )
  398.         Terminates a colon definition. Compiles the runtime code to remove a
  399.         nesting level, and changes STATE so that compilation will terminate.
  400.  
  401. RECURSIVE       ( -- )
  402.         Allow the current definition to be self referencing.
  403.  
  404. CONSTANT        <name> ( n -- )
  405.         A defining word that creates constants. At runtime the value of the
  406.         constant is placed on the stack.
  407.  
  408. VARIABLE        <name>  ( -- )
  409.         A defining word to create variables. At runtime the address of the
  410.         variable is placed on the stack.
  411.  
  412. DEFER           <name> ( -- )
  413.         Define a vectored execution word. These are initially set to display
  414.         an error message. They are initialized with IS. 
  415.  
  416. VOCABULARY      ( -- )
  417.         Defines a new Forth vocabulary. 
  418.  
  419. DEFINITIONS     ( -- )
  420.         Subsequent definitions will be placed into CURRENT. 
  421.  
  422. 2CONSTANT       <name> ( d# -- )
  423.         Create a double number constant.
  424.  
  425. 2VARIABLE       <name> ( -- )
  426.         Create a double length variable.
  427.  
  428. RUN             ( --- )
  429.         Interpret or compile whatever is in the TERMINAL INPUT BUFFER.
  430.         Tests STATE, and does the appropriate thing.
  431.  
  432.  
  433.